function sum(numa, numb) {
    console.log("numa ", numa);
    console.log("numb ", numb);

}

sum(10, 20)

let nums = [100, 200]
sum(nums[0], nums[1])

//扩展运算符
sum(...nums)


let arr1 = [1, 2, 3];
let arr2 = [4, 5, 6]


//arr1 for  push
// console.log("arr1.concat(arr2)", arr1.concat(arr2));

//扁平化 
// let newArr = [...[], ...arr2]
let newArr = [...arr1, ...arr2]
console.log("newArr", newArr);

let x = -1;
const arr = [
    ...(x > 0 ? ['a'] : []),
    'b',
];
console.log("arr", arr);



// 数组的复制
//1 原始方式
// const a1 = [1, 2];
// const a2 = a1;
// a1[0] = 100;

// console.log("a1", a1);
// console.log("a2", a2);

const a1 = [1, 2];
//写法1
// const a2 = [...a1];
// const a2 = [a1[0],a1[2]];
// 写法二
// const [...a2] = a1;

a1[0] = 100;

console.log("a1", a1);
console.log("a2", a2);



let myarr = [100, 200, 300]
// let myarr0 = myarr[0]
// let myarr1 = myarr[1]
// let myarr2 = myarr[2]

let [myarr0, myarr1, myarr2] = myarr;
// let numsArr = []
let [...numsArr] = myarr
console.log("numsArr", numsArr);


